/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package web;

import webshop.Klant;
import webshop.webshopManager;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
/**
 * @date Oct 29, 2011
 * @author Niko
 */

@Named(value = "klantController")
@RequestScoped
public class KlantController 
{
    @EJB
    private webshopManager ejb;
    private Klant klant;
    private List<Klant> klantList;
    
    @PostConstruct
    private void init()
    {
        setKlant(new Klant());
        setKlantList(ejb.findAllClients());
    }

    public Klant getKlant() 
    {
        return klant;
    }

    public void setKlant(Klant klant) 
    {
        this.klant = klant;
    }

    public List<Klant> getKlantList() 
    {
        return klantList;
    }

    public void setKlantList(List<Klant> klantList) 
    {
        this.klantList = klantList;
    }
    
    public String createKlant()
    {
        klant = ejb.createKlant(klant);
        klantList = ejb.findAllClients();
        return "listKlanten.xhtml";
    }

}
